<?php
#============================
#	Filename: additon_all.qgmod.php
#	Note	: 相册列表
#	Version : 2.0
#	Author  : ovsexia
#	Update  : 2017-8-23
#============================
global $FS,$DB,$PA,$prefix,$bi;
$md5 = md5(LANGUAGE_ID."_".$proID."_".$limit);
$cache_file = "data/cache/additon_".$md5.".php";#[缓存文件]
$check_status = false;
if($iscache)
{
	$check_status = CheckCache($cache_file);#[判断缓存文件的存储状态]
}
if($check_status)
{
	include_once($cache_file);
	unset($cache_file);
	return $list;
}
#[读取组信息]
$sql = "SELECT id FROM ".$prefix."category WHERE status='1' AND language='".LANGUAGE_ID."'";
$rslist = $DB->qgGetAll($sql);
unset($sql);
if(!$rslist)
{
	unset($cache_file);
	return false;
}
foreach($rslist AS $key=>$value)
{
	$catelist[] = $value["id"];
}
unset($rslist);
$type = $albumtype;
$sql = "SELECT m.*,m.subject".$bi.",c.catename".$bi." FROM ".$prefix."msg AS m,".$prefix."category AS c WHERE m.cateid in(".implode(",",$catelist).") AND m.ifcheck='1' AND m.additonid='".$proID."' AND m.albumtype='".$type."' AND m.cateid=c.id ORDER BY";

$sql .= " m.istop DESC,m.allsortid ASC,m.sortid ASC,m.postdate DESC,m.id DESC";

$sql .= " LIMIT 0,".$limit;

$rslist = $DB->qgGetAll($sql);

$i = 1;
foreach($rslist AS $key=>$value)
{
	$value["subject"] = $value["subject".$bi];
	
	$sql = "SELECT * FROM ".$prefix."upfiles where id =".$value["thumb"];
	$rs = $DB->qgGetOne($sql);
	$value["folder"] = $rs["folder"];
	$value["filename"] = $rs["filename"];
	$value["markfile"] = $rs["markfile"];
	$value["thumbfile"] = $rs["thumbfile"];
	//裁剪图片
	$sysimg = $PA->sysize($value["cateid"]);
	$swidth = $sysimg["width"];
	$sheight = $sysimg["height"];
	$value["cutimg"] = "images.php?imgurl=".base64_encode($value["folder"].$value["filename"])."&swidth=".$swidth."&sheight=".$sheight;

	$sql = "SELECT * FROM ".$prefix."msg_content where id =".$value["id"];
	$rs = $DB->qgGetOne($sql);
	$value["content"] = $rs["content".$bi];
	$value["cut_content"] = strip_tags($value["content"]);
	$value["cut_content"] = CutString(str_replace(array("<p>","</p>","<div>","</div>","<br />","&nbsp;","　"),array("","","","","","",""),$value["cut_content"]),200);
	
	#[获取自定义字段]
	$value["fieldlist"] = $PA->fieldlist($value["id"]);
	if($value["fieldlist"])
	{
		foreach($value["fieldlist"] AS $key2=>$value2)
		{
			$value[$value2["sign"]] = $value2["field_content"];
		}
	}
	
	#[日期转换]
	$value["year"] = date("Y",$value["postdate"]);
	$value["day"] = date("d",$value["postdate"]);
	$value["month"] = monthc(date("m",$value["postdate"]),"min"); //[min] or [ful]

	//首项尾项
	if($i==1)
	{
		$value["first"] = true;
	}
	if($i==count($rslist))
	{
		$value["last"] = true;
	}
	$value["row_index"] = $i;
	$i ++;
	$additionlist[] = $value;	
}
unset($sql);
if(!$additionlist)
{
	return false;
}
$list = _____QGMODULE_CLEARUP_LIST($additionlist,0,true);
$FS->qgWrite($list,$cache_file,"list");
unset($additionlist,$cache_file);
return $list;
?>